#!/usr/bin/env bash

# ----------------------------------------------------------------------
# Filename :  05-newDeploy-dev.sh
# Version  :  1.0
# Date     :  2020/07/08
# Author   :  Lz
# Email    :  lz843723683@gmail.com
# History  :     
#             Version 1.0, 2020/07/08
# Function :  联研院开发版 - new_deploy目录
# Out:        
#              0 => TPASS
#              1 => TFAIL
#              other=> TCONF
# ----------------------------------------------------------------------

## TODO : 测试收尾清除工作
#
NewDeployClean_FTLYY_DEV(){
	return $TPASS
}


## TODO: 调用程序退出函数
#    In: $1 => 调用脚本结果值
NewDeployExit_FTLYY_DEV(){
        # 调用退出函数，其中调用了clean相关函数
	Exit_FTLIB ${1}
}


## TODO: 用户界面
#
NewDeployUSAGE_FTLYY_DEV(){
	USAGE_FTLIB "联研院开发版 - new_deploy目录"
}


## TODO : 测试前的初始化 
#  Out  : 
#         0 => TPASS
#         1 => TFAIL
#         other=> TCONF
NewDeployInit_FTLYY_DEV(){
        # 调用初始化函数
	Init_FTLIB "NewDeployClean_FTLYY_DEV"
        # 调用用户界面函数
 	NewDeployUSAGE_FTLYY_DEV
}


## TODO ：/root下存在new_deploy_16_7目录
#
NewDeployTest01_FTLYY_DEV(){
        local path="/root"
	local pathname="new_deploy_16_7"
	
	ls ${path} | grep ${pathname}
	if [ $? -eq 0 ];then
	# 存在目录
		ls -ald ${path}/$(ls ${path} | grep ${pathname})
	        RetParse_FTLIB "要求 ${path} 中存在目录 ${pathname}" "False"
	else
	# 不存在目录
		echo "不存在目录 ${path}/${pathname}"
		OutputRet_FTLIB "${TFAIL}"
	        RetParse_FTLIB "要求 ${path} 中存在目录 ${pathname}" "False"
	fi
}


## TODO ：/etc/profile存在指定配置文件
#
NewDeployTest02_FTLYY_DEV(){
        local cfgfile="/etc/profile"
        local field="export ORACLE_HOME=\"/usr/lib/oracle/11.2/client\""

        # 判断配置文件
        echo 'cat' "${cfgfile}"
        cat ${cfgfile} | grep "${field}"
        RetParse_FTLIB "${cfgfile} 存在配置 ${field}" "False"
}


## TODO ：判断是否执行setup.sh
#
#NewDeployTest03_FTLYY_DEV(){
#	local oraclepath="/usr/lib/oracle/11.2/client"
#
#	echo "echo ${ORACLE_HOME}"
#	echo ${ORACLE_HOME} | grep ${oraclepath}
#        RetParse_FTLIB "存在环境变量 ORACLE_HOME，并且值为 ${oraclepath}" "False"
#}


## TODO : Main
#  Out  : 
#         0 => TPASS
#         1 => TFAIL
#         other => TCONF
NewDeployMain_FTLYY_DEV(){
	NewDeployInit_FTLYY_DEV

	NewDeployTest01_FTLYY_DEV

	NewDeployTest02_FTLYY_DEV

#	NewDeployTest03_FTLYY_DEV

	return ${TPASS}	
}

NewDeployMain_FTLYY_DEV
NewDeployExit_FTLYY_DEV $?
